﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Text;
using System.Threading.Tasks;

namespace CashAgent
{
    /// <summary>
    /// 请求工具类
    /// </summary>
    public class RequestUtil
    {
        static string uriHost = "https://api.workcrm.cn";

        public static string Reqest(string requestUri, string contentStr)
        {
            var content = new StringContent(contentStr, Encoding.UTF8, "text/json");
            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(uriHost);
                //授权
                client.DefaultRequestHeaders.Add("Authorization", "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6IjFiYjM2YTY5MzczODkyOTQ0Yzk1ZTIyYjM1MjI3NjY4NzM0NTljODRhZWIxYmJjMWE0MTQwZGExMzFlMGUyMWY1YjI0NGUwZjJmMDhmMDNlIn0.eyJhdWQiOiIxIiwianRpIjoiMWJiMzZhNjkzNzM4OTI5NDRjOTVlMjJiMzUyMjc2Njg3MzQ1OWM4NGFlYjFiYmMxYTQxNDBkYTEzMWUwZTIxZjViMjQ0ZTBmMmYwOGYwM2UiLCJpYXQiOjE1MzYyMjI0MTMsIm5iZiI6MTUzNjIyMjQxMywiZXhwIjoxNjkzOTg4ODEzLCJzdWIiOiI0Iiwic2NvcGVzIjpbIioiXX0.QmhSb9hooL7HviefIm3vkONBOTheEqbr8uHEEbXLd-FQrtuZmieDBXvMMPWx-UnRAEAibPJrNd26V4NDZEir_MB2XO6shF0ITQMsIFcdmriEpy8-tDjsKUsGTPdjiAxhsZNKYonyy8Xr027a6LsCwK5pVTiSKmius0q0DylO5pRl5c_b8RiMTXGMlAIQzp_7rs96FQsHY2jsllW2EKXgBHGU8Kx-84Rs89vARENHDL-XraKa1jcFX37kIWiIS2hi99fmt2G0DJKo1fTaxd1MPDX9cFLbyvU0y_D9e3gzAtjXGZuByJWxMmafcjtWQdjJej2vfKZutiatkeohpxarha1GcHdunQAuNNoHIVtctd_zT6g_htnOGeNocXOkjnUOsUFzj_5wV8d4I89w3PTllJgchmIhx4PoMqEmKh7NuoU5A157Qhgwnzu0cp3dyUR5w55F5BAcezFLuxNoxzdFxZSdq-VK5b1_ztpwKBhFd21KbrFsbnp5UnU0CYQulHtXrKNebDGfIVMwk2h-pyZp6ITXCsBJUnQTmrvOeKaqovtvME9NevRaY0Xqad2F_iDyBCcvqYEihtOFggImd3Re5hjz9LtqjahNL-gH7KHM-s2FVRRnakwb6xFudjBeLYjw3KDgV8hG537M-QX8IZvND4WgdlTj5xphWBPiyQmHaIw");
                var result = client.PostAsync(requestUri, content).Result;
                string resultContent = result.Content.ReadAsStringAsync().Result;
                return resultContent;
            }
        }
    }
}
